package xju_9_10.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import xju_9_10.entity.User;
import xju_9_10.service.UserService;

import java.util.Arrays;

@Controller
public class UserController {

    @Autowired
    private UserService userService;

    @GetMapping("/user")
    public String user(Model model, @RequestParam("username")String username, @RequestParam("password")String password) {
        User user = userService.login(username,password);
        model.addAttribute("users", Arrays.asList(user));
        return "list";
    }
}
